package org.noote.libs.virtualpad;

public class VirtualVerticalSlider extends VirtualTouchPad {
	
	protected boolean _bCursorPressed = false;
	
	protected boolean _bEnableLockMode = false;
	protected boolean _bLocked = false;
	
	protected String _sText = "";
	
	protected float _fCursorPosition = 0.0f;
	
	public VirtualVerticalSlider()
	{
		super();
	}
	public VirtualVerticalSlider(boolean bLock)
	{
		super();
		_bEnableLockMode = bLock;
	}

	public void setText(String sText)
	{
		_sText = sText;	
	}
	
	@Override
	protected void _checkButtons()
	{
		_bCursorPressed = false;
		
		if(_iState == TOUCH_MOVED)
			_iState = TOUCH_PRESSED;

		if((_iState == TOUCH_RELEASED && _iOldState == TOUCH_PRESSED)
				|| (_iOldState == TOUCH_RELEASED && _iState == TOUCH_PRESSED))
			_bNewEvent = true;
		
		if(_iState == TOUCH_PRESSED)
		{
			_bCursorPressed = true;
			_fCursorPosition = (1.0f+_fPosition_Y)/2.0f;
		}
		if(_bEnableLockMode)
		{
			if(_iOldState == TOUCH_RELEASED && _iState == TOUCH_PRESSED)
				_bLocked = !_bLocked;
		}
	}

	public void enableLock(boolean bLock)
	{
		_bEnableLockMode = bLock;
	}
	public boolean isLockable()
	{
		return _bEnableLockMode;
	}
	public void setLock(boolean bLock)
	{
		_bLocked = bLock;
	}
	public boolean isLocked()
	{
		return _bLocked;
	}

	public boolean getPressed(){return _bCursorPressed;}
	public float getPosition(){return _fCursorPosition;}
	public void setPosition(float fCursorPosition){_fCursorPosition = fCursorPosition<0.0f?0.0f:fCursorPosition>1.0f?1.0f:fCursorPosition; _bNewEvent = true;}
}
